import Vue from 'vue'
import App from './App'

import '../node_modules/bootstrap/dist/css/bootstrap.min.css'
import router from './router/router.js'
import store from './store/store.js'

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
});

router.beforeEach((to, from, next)=>{
    let user = localStorage.getItem('user');
    if(to.path != '/login'){
      if(user){
        next();
      }else{
        next({
          path: '/login',
          query: { redirect: to.fullPath }
        })
      }
    }else{
      next();
    }

    

})
